﻿//url:请求地址,不能为空注意，必须是"Handler.ashx?key="格式 key代表是哪个功能，具体查看KeyMapInfo对应的类型
//requestType：请求类型，可以为null 
//data:请求附加的数据,可以为null
//dataType:请求附加的数据类型,，可以为null
//successHandel:请求成功后的回调函数,，可以为null
//failHandel:请求失败后的回调函数,，可以为null #f3f8ff

function ajaxProcess(req)
{
	ajaxRequest(req.url, req.requestType, req.data, req.dataType, req.successHandle, req.failHandle, req.obj,req.async,req.traditional,req.resultHandler);
}

function ajaxRequest(url, requestType, data, dataType, successHandle, failHandle,obj,async,traditional, resultHandler) {
    var reqType = "POST";
    var reqDataType = "JSON";
    var reqURL =  url;   
    
    if (!isEmpty(requestType))
        reqType = requestType;

    if (!isEmpty(dataType))
        reqDataType = dataType;
    
    var asyncType=true;
    if(!isEmpty(async))
    	asyncType=async;
    	
    var traditionalType=false;
    if(!isEmpty(traditional))
    	traditionalType=traditional;
    	
    
    //blockUI();
    $.ajax({
        type: reqType,
        url: reqURL,
        data: data,
        async:asyncType,
        traditional:traditionalType,
        success: null,
        timeout: 60000, //60秒超时
        dataType: reqDataType
    })
    .success(function (data) {
        unblockUI();
        if(typeof(data) === "string"){
        	data = JSON.parse(data);
        }
        if (!data.result&& !isEmpty(data.message))
        { 
            if (!isEmpty(obj)) {
                $(obj).html('<div class="prompt"><div class="info"> '+data.message+'</div></div>');
            }
            else {
                ShowMessage(data.message);
            }
            if(!isEmpty(resultHandler)){
            	resultHandler(data);
            }
            return;
        }
//        if(data.result && !isEmpty(data.message) ){
//        	ShowMessage(data.message);
//        }
        if (!isEmpty(successHandle)) {
        	successHandle(data, obj);
        }
    })
    .error(function (data) {
        unblockUI();
        if (!isEmpty(failHandle)) failHandle(data, obj);
        else FailCallBack(data, obj);
    })
}

//AJAX请求失败的默认方法
function FailCallBack(rep, obj) {
    if (rep.statusText === "timeout") {
        if (obj !== null) {
            $(obj).html('<div class="prompt"><div class="info"> 请求超时！</div></div>');
        }
        else {
            ShowMessage( '请求超时！', 'info');
        }
    }
    else {
        if (obj !== null) {
            $(obj).html('<div class="prompt"><div class="info"> 请求失败！</div></div>');
        }
        else {
            ShowMessage('请求失败！');
        }
    }
}

//弹出消息的封装
function ShowMessage(msg, msgType) {
    if (msgType === 'error') {
    	baseShowMessage({msg:msg});
    }
    else if (msgType === 'info') {
    	$.messager.show({
            title: "操作提示",
            msg: msg,
            showType: 'slide',
            timeout: 2000,
            style:{
        		right:'',
        		top:'200px',
        		bottom:''
        	}
        });
    }
    else {
    	baseShowMessage({msg:msg});
   }
	
}


function baseShowMessage(obj){
	
	if(!obj.fn){
		$.messager.alert('提示', obj.msg, 'warning');
	}else{
		$.messager.alert({
			title: '提示',
			msg: obj.msg,
			fn: obj.fn
		});
	}
}


//用户登出
function Logout() {
	var url = "/"+projectName+"/bfs/user/loginout";        
    ajaxRequest(url, null, null, null,
        function() {
            var myLoginURL = "/bfs/login.html";
            window.location.href = myLoginURL;
        },
        null);}

//正在加载....
function blockUI(){
    /*var lockdiv= $("<div class=\"loading-mask\"></div>");
        $(lockdiv).css({ display: "block", width: "100%", height: $(window).height()});
        $(lockdiv).appendTo("body");
     var loaddiv=$("<div class=\"loading-mask-msg\">正在加载，请稍候...</div>")
        $(loaddiv).css({ display: "block", left: ($(document.body).outerWidth(true) - 190) / 2, top: ($(window).height() - 45) / 2 });  
        $(loaddiv).appendTo("body");   */
	
	var loaddiv=$("<div class=\"loading-bomb\"><div class=\"loading-box\"><div class=\"loader\"><div class=\"loader-inner pacman  fl\"><div></div><div></div><div></div><div></div><div></div></div><p class=\"fl loader-text\">正在加载中，请稍后...</p></div></div></div>");	
	$(loaddiv).prependTo(".right-content");
	$(loaddiv).css({ display: "block", width: "100%", height: $(".right-content").height()});
	$(".loading-box").css({ left: ($(".right-content").outerWidth(true) - 190) / 2-30, top: ($(".right-content").height() - 45) / 2 });  
}

//取消加载层  
function unblockUI() {  
   /*$(".loading-mask").remove();  
   $(".loading-mask-msg").remove();  */
   $(".loading-bomb").remove(); 
}

//扩展
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (!isEmpty(r)){
    	return decodeURIComponent(r[2]); 
    }
    return null;
}

/********************** String工具类***************/
//trim去掉字符串两边的指定字符,默去空格
String.prototype.trim = function(tag) {
  if (!tag) { 
      tag = '\\s';
  }else { 
      if (tag === '\\') { 
      tag = '\\\\'; 
  } else if (tag === ',' || tag === '|' || tag === ';') { 
          tag = '\\' + tag; 
      }else { 
          tag = '\\s'; 
      } 
  }
  eval('var reg=/(^' + tag + '+)|(' + tag + '+$)/g;'); 
  return this.replace(reg, '');
};
//字符串截取后面加入...
String.prototype.interceptString = function(len) {
  if (this.length > len) {
      return this.substring(0, len) + "...";
  } else {
      return this;
  }
}
//将一个字符串用给定的字符变成数组
String.prototype.toArray = function(tag) {
  if (this.indexOf(tag) !== -1) {
      return this.split(tag);
  }else {
      if (this !== '') {
          return [this.toString()];
      }else {
          return [];
      }
  }
}
//只留下数字(0123456789)
String.prototype.toNumber= function() { 
  return this.replace(/\D/g, ""); 
}
//转成int
String.prototype.toInt= function() {  
  var temp = this.replace(/\D/g, "");
  return isNaN(parseInt(temp)) ? this.toString() : parseInt(temp);  
}
//是否是以XX开头
String.prototype.startsWith= function(tag){
  return this.substring(0, tag.length) === tag;
}
//是否已XX结尾
String.prototype.endWith= function(tag){
  return this.substring(this.length - tag.length) === tag;
}
String.prototype.replaceAll = function(s1,s2){
	  return this.replace(new RegExp(s1,"gm"),s2);
	} 
//StringBuffer
var StringBuffer = function() {
  this._strs = []; 
};
StringBuffer.prototype.append = function (str) { 
  this._strs.push(str); 
}; 
StringBuffer.prototype.toString = function() { 
  return this._strs.join(""); 
}; 
/**************Array 扩展属性****************************/
//根据数据取得再数组中的索引
Array.prototype.getIndex = function(obj){
  for (var i = 0; i < this.length; i++) {
      if (obj === this[i]) {
          return i;
      }
  }
  return -1;
}
//移除数组中的某元素
Array.prototype.remove= function (obj) {
  for (var i = 0; i < this.length; i++) {
      if (obj === this[i]) {
          this.splice(i, 1);
          break;
      }
  }
  return this;
}
//判断元素是否在数组中
Array.prototype.contains= function (obj) {
  for (var i = 0; i < this.length; i++) {
      if (obj === this[i]) {
          return true;
      }
  }
  return false;
}  
//cookie操作
var CookieUtil={
    path: "/",
    domain: window.location.host,
    add: function(name,val){
        $.cookie(name, val, {expires: 7, path: this.path, domain: this.domain, secure: true});
    },
    remove: function(name){
        $.cookie(name, null,{path: this.path, domain: this.domain});
    },
    get: function(name){
         $.cookie(name,{path: this.path, domain: this.domain});
    }
}
//error
var error={
     e_404: function(){
    	 ShowMessage("404 - 未找到改页面！","warning");
     },
     e_500: function(){
    	 ShowMessage("500 - 服务器内部错误！","error");
     },
     e_403: function(){
    	 ShowMessage("403 - 权限不足！","warning");
     }
}     
/***********常用类型判断********************************/
function isEmail(s) {
        return s.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) !== -1;
};
function isfloat(oNum) {
    if (!oNum) {
    	return false;
    }
    var strP = /^\d+(\.\d+)?$/;
    if (!strP.test(oNum)){
    	return false;
    }
    try {
        if (parseFloat(oNum) !== oNum) {
        	return false;
        }
    } catch (ex) {
        return false;
    }
    return true;
};

function isNumber(oNum) {
    if (!oNum) {
    	return false;
    }
    var strP = /^\d+$/; //正整数
    if (!strP.test(oNum)) {
    	return false;
    }
    return true;
};
function isEmpty(val) {
        return (val === null || typeof(val) === "undefined")|| (typeof(val) === "string"&&val === ""&&val !== "undefined")||val === "[]";
}

/**********form表单 提交返回函数**********/
$.resultHandler = function(jsonString, callable) {
	var data = jsonString;
	if(typeof data === 'string'){
		data = $.parseJSON(data);
	}
	if(data.result){
		if (!isEmpty(data.message)){
			ShowMessage(data.message, 'error');
			return false;
		}
	}else{
		if (!isEmpty(data.message)){
			ShowMessage(data.message, 'error');
			return false;
		}
		else
		{
		    ShowMessage('操作失败!', 'error');
		    return false;
		}
	}
	callable && callable.call();
};

//ajax请求跳转登录页面
$.ajaxSetup({ 
　　　　complete:function(XMLHttpRequest){ 
　　　　　　var unauthorized=XMLHttpRequest.getResponseHeader("unauthorized"); 
　　　　　　if(unauthorized === 'true'){ 
　　　　　　　　//指定要跳转的页面 
　　　　　　　　top.location.href = "http://"+window.location.host+"/bfs/login.html"; 
　　　　　　} 
　　　　} 
});

//日期格式化
Date.prototype.format = function(fmt)
{
	// 对Date的扩展，将 Date 转化为指定格式的String
	// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符，
	// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
	// 例子：
	// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
	// (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
	var o = {
	        "M+": this.getMonth() + 1, // 月份
	        "d+": this.getDate(), // 日
	        "h+": this.getHours(), // 小时
	        "m+": this.getMinutes(), // 分
	        "s+": this.getSeconds(), // 秒
	        "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
	        "S": this.getMilliseconds() // 毫秒
	    };
	    if (/(y+)/.test(fmt)) {
	    	fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	    }
	    for (var k in o){
	    	  if (new RegExp("(" + k + ")").test(fmt)){
	  	    	fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	  	    }	
	    }
	  
	    return fmt;
}
//计算当前日期在本年度的周数   // 注意：JS 中月的取值范围为 0~11 
Date.prototype.getWeekOfYear = function(weekStart) { // weekStart：每周开始于周几：周日：0，周一：1，周二：2 ...，默认为周日  
    weekStart = (weekStart || 0) - 0;  
    if(isNaN(weekStart) || weekStart > 6)  
        weekStart = 0;    
  
    var year = this.getFullYear();  
    var firstDay = new Date(year, 0, 1);  
    var firstWeekDays = 7 - firstDay.getDay() + weekStart;  
    var dayOfYear = (((new Date(year, this.getMonth(), this.getDate())) - firstDay) / (24 * 3600 * 1000)) + 1;  
    return Math.ceil((dayOfYear - firstWeekDays) / 7) + 1;  
}  
  
// 计算当前日期在本月份的周数   // 注意：JS 中月的取值范围为 0~11 
Date.prototype.getWeekOfMonth = function(weekStart) {  
    weekStart = (weekStart || 0) - 0;  
    if(isNaN(weekStart) || weekStart > 6)  
        weekStart = 0;  
  
    var dayOfWeek = this.getDay();  
    var day = this.getDate();  
    return Math.ceil((day - dayOfWeek - 1) / 7) + ((dayOfWeek >= weekStart) ? 1 : 0);  
} 
function dateFormatter(date) {
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    var d = date.getDate();
    return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d);
};

function dateTimeFormatter(date) {
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    var d = date.getDate();
    var h = date.getHours();
    var mi = date.getMinutes();
    var s = date.getSeconds();
    return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)+ ' ' + (h < 10 ? ('0' + h) : h)+ ':' + (mi < 10 ? ('0' + mi) : mi)+ ':' + (s < 10 ? ('0' + s) : s);
};

function dateParser(s) {
    if (!s) {
    	return new Date();
    }
    var ss = s.split('-');
    var y = parseInt(ss[0], 10);
    var m = parseInt(ss[1], 10);
    var d = parseInt(ss[2], 10);
    if (!isNaN(y) && !isNaN(m) && !isNaN(d)) {
        return new Date(y, m - 1, d);
    } else {
        return new Date();
    }
};
//计算天数差的函数，通用   sDate1和sDate2是2006-12-18格式  
function  DateDiff(sDate1, sDate2){     
    var aDate, oDate1, oDate2, iDays;
    aDate = sDate1.split("-");
    oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) ;   //转换为12-18-2006格式  
    aDate = sDate2.split("-") ; 
    oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) ; 
    iDays = parseInt(Math.abs(oDate1 - oDate2)/1000/60/60/24) ;   //把相差的毫秒数转换为天数  
    return iDays;
}    

function addDate(date, days) {
    if (days == undefined || days == '') {
        days = 1;
    }
    var date = new Date(date.replace(/-/g,"/"));
    date.setDate(date.getDate() + days);
    date = new Date(date);
    var m = date.getMonth() + 1;
    var d = date.getDate();
    return date.getFullYear() + '-' + (m<10?('0'+m):m) + '-' + (d<10?('0'+d):d);
}

function addDateMonth(date, months) {
    if (months == undefined || months == '') {
    	months = 1;
    }
    var date = new Date(date.replace(/-/g,"/"));
    date.setMonth(date.getMonth() + months);
    var m = date.getMonth() + 1;
    var d = date.getDate();
    return date.getFullYear() + '-' + (m<10?('0'+m):m) + '-' + (d<10?('0'+d):d);
}

function addMonth(date, months) {
    if (months == undefined || months == '') {
    	months = 1;
    }
    var date = new Date(date.replace(/-/g,"/"));
    date.setMonth(date.getMonth() + months);
    var m = date.getMonth() + 1;
    return date.getFullYear() + '-' + (m<10?('0'+m):m);
}

function getPageSize() {
    var xScroll, yScroll,pageWidth,pageHeight;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else {
        if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac    
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari    
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer    
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode    
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else {
            if (document.body) { // other Explorers    
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
        }
    }
    // for small pages with total height less then height of the viewport    
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }
    // for small pages with total width less then width of the viewport    
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }
    var arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    var arrRet = {
        PageWidth: pageWidth,
        PageHeight: pageHeight,
        WindowWidth: windowWidth,
        WindowHeight: windowHeight
    };
    return arrRet;   // arrayPageSize;
};

//系统弹出框
function zeeiDialog(options){
    // 创建一个父div
	var wdiv=$('<div></div>'); 
	var winId = 'Win_'+Math.random();
	var maximizable = false;
	var minimizable = false;
	var resizable = false;
	if (options.id != undefined && options.id != null && options.id != ""){
		winId = options.id;
	}
	if (options.maximizable != undefined && options.maximizable != null && options.maximizable != "") {
		maximizable = true;
	}
	if (options.minimizable != undefined && options.minimizable != null && options.minimizable != "") {
		minimizable = true;
	}
	if($("#"+winId).length>0){
		$("#"+winId).remove();
	}
	 var _default={
	     id: winId,
	     href: '',
	     title: 'title',
	     collapsible:false,
	     maximizable:maximizable,
	     minimizable:minimizable,
	     modal:false,
	     data: {},
	     width: $(window).width(),
	     height: $(window).height(),
	     resizable:false,
	     top:null,
	     left:null,
	     modal:true,
	     inline:true,
	     onBeforeClose:function(){
	         // _default.callback();
	     },
	     refresh:function(){
	     },
	     callback: function() {},
	     close:function(flag, data){ 
	         var isCall=true;
	         if(flag!=undefined && flag!=null)
	         {
	             isCall=flag;
	         }
	         if(isCall) _default.callback(isCall, data);
	         wdiv.window("close",isCall);
	         wdiv.window("destroy",isCall);
	     }
	 };
	 
	 _default = $.extend({}, _default, options);	 
	 _default.top=($(window).height()-_default.height)/2;
	 _default.left=($(window).width()-_default.width)/2;
	
	 var wiframe=$("<iframe frameborder='0' scrolling='no' style='width:100%;height:100%;'></iframe>");
	 $(wiframe).attr("id",_default.id+"_iframe");
	 $(wiframe).attr("src",_default.href);  
	 if (options.maxHeight != undefined && options.maxHeight != null && options.maxHeight != "") {
		 $(wiframe).css("height",(options.maxHeight -40) + "px");
	 } else {
		 $(wiframe).css("height",(_default.height-35) + "px");
	 }
	 $(wdiv).append(wiframe);       
	 $(document.body).append(wdiv);
	 $(wiframe)[0].api=_default;
	 wdiv.window({
	     id: _default.id,
	     width:_default.width,
	     height:_default.height, 
	     collapsible:_default.collapsible,
	     maximizable:_default.maximizable,
	     minimizable:_default.minimizable,  
	     modal:_default.modal,
	     inline:true,
	     title:_default.title,        
	     top:_default.top,
	     left:_default.left,
	     maxHeight: options.maxHeight - 20,
	     maxWidth: $(window).width() - 20,
	     resizable:_default.resizable,
	     onBeforeClose:_default.onBeforeClose,
	     close:_default.close
	 });
	 wdiv.window('open');
}

/** 带回调函数弹出框，同时支持弹窗匡返回值 * */
function openModalDialog(title, url, param, width, height, refreshData){
	window.top.zeeiDialog({
     title: title,
     href : url,
     data: param,
     width: width,
     height: height,
     modal: true,
     callback: function (bFlag, data) {
         if (bFlag) {
         	refreshData(data);
         }
     }
 });
}

/** 普通函数弹出框 * */
function openDialog(title, url, param, width, height){
	window.top.zeeiDialog({
     title: title,
     href : url,
     data: param,
     width: width,
     height: height,
     modal: true
 });
}

/** 带id的普通函数弹出框 **/
function openDialogById(id, title, url, param, width, height, maximizable, minimizable, maxHeight){
	window.top.zeeiDialog({
		id : id,
     title: title,
     href : url,
     data: param,
     width: width,
     height: height,
     maximizable: maximizable,
     minimizable: minimizable,
     maxHeight: maxHeight,
     modal: true
 });
}

/** 深度克隆 */
function deepClone(o){
    if (o instanceof Array) {
        var n = [];
        for (var i = 0; i < o.length; ++i) {
            n[i] = deepClone(o[i]);
        }
        return n;

    } else if (o instanceof Object) {
        var n = {}
        for (var i in o) {
            n[i] = deepClone(o[i]);
        }
        return n;
    } else {
        return o;
    }
}

function uploadify(req)
{ 
    var h5Type='';
    
    if(req.fileTypeExts === '*.*'){
        h5Type=false;
    }else{
        if(req.fileTypeExts.indexOf('jpg')>-1||req.fileTypeExts.indexOf('png')>-1||req.fileTypeExts.indexOf('gif')>-1){
            h5Type+='image/png,image/jpg,image/jpeg|';
        }else if(req.fileTypeExts.indexOf('zip')>-1||req.fileTypeExts.indexOf('rar')>-1){
            h5Type+='application|';
        }else if(req.fileTypeExts.indexOf('xml')>-1){
            h5Type+='text|';
        }
        h5Type=h5Type.substring(0,h5Type.length-1); 
    }
    
	if (window.applicationCache) {
		req.DOM.uploadifive({  
	        'buttonText' : req.buttonText,  //上传按钮显示内容，还有个属性可以设置按钮的背景图片
	        'height' : req.height,  
	        'uploadScript' : req.uploader,   // 后台处理的请求地址，后面追加了jsessionid，用来标示使用当前session（默认是打开新的session，会导致存在session校验的请求中产生302错误）
	       // 'cancelImg'      : req.cancelImg, 
	        'width' : req.width,  
	        'removeCompleted' : true,
	        'queueID' : 'tip-queue',
	        'fileSizeLimit' : req.fileSizeLimit,  
	        'multi' : req.multi,  // true 选择多文件上传
	        'auto':req.auto,  // true自动上传
	        'fileObjName'   : req.fileObjName,  //文件对象名称,用于后台获取文件对象时使用,详见下面的java代码  
	        'fileType' :  h5Type, //控制可上传文件的扩展名，启用本项时需同时声明fileDesc 
	        'fileTypeExts' : req.fileTypeExts, 
	        'onFallback' : function() {//检测H5失败调用  
	            req.onFallback(); 
	        },  
	        'onUploadStart' : function(file) {
                var param = {};
                param.pathState = "true";
                req.DOM.uploadify("settings", "formData", param);
                },
	        'onUploadComplete' : function(file, data, response) {
	        	req.onUploadSuccess(file, data, response);
	        }  
	    }); 
	} else {
    	req.DOM.uploadify({  
            'buttonText' : req.buttonText,  //上传按钮显示内容，还有个属性可以设置按钮的背景图片
            'height' : req.height,  
            'swf' : req.swf,  // 控件flash文件位置  
            'uploader' : req.uploader,   // 后台处理的请求地址，后面追加了jsessionid，用来标示使用当前session（默认是打开新的session，会导致存在session校验的请求中产生302错误）
            //'cancelImg'      : req.cancelImg, 
            'width' : req.width,  
            'removeCompleted' : true,
            'fileSizeLimit' : req.fileSizeLimit,  
            'multi' : req.multi,  // true 选择多文件上传
            'auto':req.auto,  // true自动上传
            'fileObjName'   : req.fileObjName,  //文件对象名称,用于后台获取文件对象时使用,详见下面的java代码  
            'fileTypeExts' : req.fileTypeExts, //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
            'onFallback' : function() {//检测FLASH失败调用  
                req.onFallback(); 
            },  
            'onUploadStart' : function(file) {
                var param = {};
                param.pathState = "true";
                req.DOM.uploadify("settings", "formData", param);
                },
            'onUploadSuccess' : function(file, data, response) {
            	req.onUploadSuccess(file, data, response);
            }  
        }); 
    }
}
/**
 * easyui combobox 开启搜索功能,自动装载选中的项目处理函数
 */
function onComboboxHidePanel() {
    var el = $(this);
    el.combobox('textbox').focus();
    // 检查录入内容是否在数据里
    var opts = el.combobox("options");
    var data = el.combobox("getData");
    var value = el.combobox("getValue");
    // 有高亮选中的项目, 则不进一步处理
    var panel = el.combobox("panel");
    var items = panel.find(".combobox-item-selected");
    if (items.length > 0) {
        var values = el.combobox("getValues");
        el.combobox("setValues", values);
        return;
    }
    var allowInput = opts.allowInput;
    if (allowInput) {
        var idx = data.length;

        data[idx] = [];
        data[idx][opts.textField] = value;
        data[idx][opts.valueField] = value;
        el.combobox("loadData", data);
    } else {
        // 不允许录入任意项, 则清空
        el.combobox("clear");
    }
}

function  getSysPointName(systemType) {
	var pointName = "测点";
	switch (parseInt(systemType)) {
	case 22:
		pointName = "测点";
		break;
	case 51:
	case 52:
		pointName = "站点";
		break;
	case 31:
	case 32:
	case 104:
		pointName = "排口";
		break;
	default:
		pointName = "测点";
		break;
	}

	return pointName;
}

function GetWindDirect(pWindDegree) {
	var windDirect = "";
	if ((pWindDegree >= 0 && pWindDegree < 11.25) || (pWindDegree >= 348.76 && pWindDegree <= 360)) {
		windDirect = "北风";
	} else if (pWindDegree > 11.25 && pWindDegree <= 33.75) {
		windDirect = "东北偏北风";
	} else if (pWindDegree > 33.75 && pWindDegree <= 56.25) {
		windDirect = "东北风";
	} else if (pWindDegree > 56.26 && pWindDegree <= 78.75) {
		windDirect = "东北偏东风";
	} else if (pWindDegree > 78.75 && pWindDegree <= 101.25) {
		windDirect = "东风";
	} else if (pWindDegree > 101.25 && pWindDegree <= 123.75) {
		windDirect = "东南偏东风";
	} else if (pWindDegree > 123.75 && pWindDegree <= 146.25) {
		windDirect = "东南风";
	} else if (pWindDegree > 146.25 && pWindDegree <= 168.75) {
		windDirect = "东南偏南风";
	} else if (pWindDegree > 168.75 && pWindDegree <= 191.25) {
		windDirect = "南风";
	} else if (pWindDegree > 191.25 && pWindDegree <= 213.75) {
		windDirect = "西南偏南风";
	} else if (pWindDegree > 213.75 && pWindDegree <= 236.25) {
		windDirect = "西南风";
	} else if (pWindDegree > 236.25 && pWindDegree <= 258.75) {
		windDirect = "西南偏西风";
	} else if (pWindDegree > 258.75 && pWindDegree <= 281.25) {
		windDirect = "西风";
	} else if (pWindDegree > 281.75 && pWindDegree <= 303.75) {
		windDirect = "西北偏西风";
	} else if (pWindDegree > 303.75 && pWindDegree <= 326.25) {
		windDirect = "西北风";
	} else if (pWindDegree > 326.25 && pWindDegree <= 348.75) {
		windDirect = "西北偏北风";
	}

	return windDirect;
}

function cancelBubble(event){
	var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
	event=event?event:window.event;
	 if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1) {
		 event=window.event;
		 event.cancelBubble = true;
	 }else{
		 event=event?event:window.event;
		 event.stopPropagation();
	 }
}